home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 2.6 KB | 99 lines | [TEXT/MPS ] |
- (*
- CTBConfigure parameters[,type] -- Configure a tool. The type parameter tells which type of
- tool ("connection", "terminal", or "file transfer") to configure; if that parameter is missing
- or empty, then it defaults to "connection". The parameters parameter is a string to be passed to
- tool to configure it. The specific details of the string contents varies depending upon the
- type of tool.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBConfigure.p
- link -m ENTRYPOINT -o HyperCommands -rt XCMD=2750 -sn Main=CTBConfigure ∂
- CTBConfigure.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBConfigure } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBConfigure(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBConfigure(paramPtr);
- end;
-
- procedure CTBConfigure(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var i: integer;
- paramStringHandle: Handle;
- tt: ToolType;
- result: integer;
- s: Str255;
- s2: Str32;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBConfigure);
- end;
-
- begin
- { Verify the number of parameters. }
- i := paramPtr^.paramCount;
- if (i = 0) or (i > 2) then Fail('Invalid parameter count');
-
- { Make sure the Comm Toolbox is present and ready. }
- CTBReady;
-
- { Get the configuration string. }
- paramStringHandle := paramPtr^.params[1];
- HLock(paramStringHandle);
- { Get the tool type to configure. }
- if i = 1 then tt := connectionTool
- else tt := GetToolTypeParm(2);
- { Configure... }
- case tt of
- connectionTool: result := CMSetConfig(Globals^^.connHand,paramStringHandle^);
- fileTransferTool: result := FTSetConfig(Globals^^.FTHand,paramStringHandle^);
- terminalTool: result := TMSetConfig(Globals^^.termHand,paramStringHandle^);
- end;
- HUnlock(paramStringHandle);
-
- { If we got an error, report it in a relatively meaningful way. }
- if result <> noErr then
- begin
- if result = -1 then
- begin
- s := 'Unknown error';
- s2 := '';
- end
- else
- begin
- LongToStr(paramPtr,result,s);
- if result < 0 then s := 'OS error: '
- else s := 'Parse failed at position: '
- end;
- Fail(Concat(Concat('Failure during configuration: ',s),s2));
- end;
- end;
-
- end.
-